/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package picturewolrd;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

/**
 *
 * @author TamWin7
 */
public class FullScreen extends JFrame {

    public FullScreen() {
        setUndecorated(true);
        initComponent();
        setExtendedState(MAXIMIZED_BOTH);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        setResizable(false);
        setPreferredSize(new Dimension(1366, 768));
        setSize(1366, 768);
        setBackground(new Color(0, 0, 0, 120));

        Screen scr = new Screen();
        String temp = scr.linkFileImage;
        if(temp != "")
        {
            pathFileName = temp;
        }
        
        System.out.println("img " + pathFileName);
        
        
        LoadImage(pathFileName);

    }

    void initComponent() {
        lbImage = new JLabel();
        lbImage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        //lbImage.setSize(500, 500);
        //lbImage.setLocation(100, 100);

        this.add(lbImage);
    }
    String pathFileName = "C:/Users/TamWin7/Desktop/Sunset.jpg";

    void LoadImage(String pathFileImage) {
        Image img = Toolkit.getDefaultToolkit().getImage(pathFileName);
        ImageIcon temp = new ImageIcon(pathFileImage);
        int w = temp.getIconWidth();
        int h = temp.getIconHeight();
        int wid = getWidth();
        int hei = getHeight();

        while (w >= 1366 || h >= 768) {
            w /= 1.5;
            h /= 1.5;
        }
        System.out.println(wid);
        System.out.println(hei);
        System.out.println(w);
        System.out.println(h);

        temp.setImage(img.getScaledInstance(w, h, Image.SCALE_DEFAULT));
        lbImage.setIcon(temp);
        lbImage.setSize(w, h);
        lbImage.setLocation(Math.abs(wid - w) / 2, Math.abs(hei - h) / 2);
    }

    public static void main(String[] args) {
        FullScreen fs = new FullScreen();
        fs.setVisible(true);
    }
    
    private JLabel lbImage;
}
